/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FrameGuia.java
 *
 * Created on 29/09/2010, 14:32:27
 */
package aprendizadosemfio.Telas;

import aprendizadosemfio.entidades.TipoDeRede;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.Toolkit;
import aprendizadosemfio.Montagem.PainelMontagemWPan;
import aprendizadosemfio.Montagem.wlan.PanelBotoes;
/**
 *
 * @author leonardo
 */
public class FrameGuia extends javax.swing.JFrame {


    private TipoDeRede tipoDeRede;

    
    /** Creates new form FrameGuia */

    PanelConceito panelConceito;
    PanelTipo panelTipo;
    PanelBotoes panelBotoes;
    
    public FrameGuia() {
        initComponents();
        //setarFullScreen();
        ajustaAmbiente();
        this.setResizable(false);
        panelConceito = new PanelConceito();
        panelTipo = new PanelTipo();
        panelBotoes = new PanelBotoes();

        PanelPrincipal.add(panelBotoes, new BorderLayout());

         double width = Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2;
        double height = Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2;
        double widthf = getWidth() / 2;
        double heigthf = getHeight() / 2;
        int widthFinal = (int) (width - widthf);
        int heigthFinal = (int) (height - heigthf);
        setLocation(widthFinal, heigthFinal);

    }

    public void setTipoDeRede(TipoDeRede tipoDeRede) {
        this.tipoDeRede = tipoDeRede;
        figuraInicial.setIcon(tipoDeRede.getImagem());
        jLabel2.setIcon(tipoDeRede.getImagemTitulo());
        jLabel2.repaint();
        figuraInicial.repaint();
        
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        PanelPrincipal = new javax.swing.JPanel();
        figuraInicial = new javax.swing.JLabel();
        jToolBar1 = new javax.swing.JToolBar();
        Conc = new javax.swing.JButton();
        Tipos = new javax.swing.JButton();
        Montar = new javax.swing.JButton();
        Principal = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));
        jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        jPanel2.setBackground(new java.awt.Color(255, 255, 255));

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 148, Short.MAX_VALUE)
        );

        jPanel3.setBackground(new java.awt.Color(255, 255, 255));
        jPanel3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resource/WLAN.png"))); // NOI18N

        PanelPrincipal.setBackground(new java.awt.Color(255, 255, 255));

        figuraInicial.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resource/wpan.jpg"))); // NOI18N

        javax.swing.GroupLayout PanelPrincipalLayout = new javax.swing.GroupLayout(PanelPrincipal);
        PanelPrincipal.setLayout(PanelPrincipalLayout);
        PanelPrincipalLayout.setHorizontalGroup(
            PanelPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PanelPrincipalLayout.createSequentialGroup()
                .addContainerGap(60, Short.MAX_VALUE)
                .addComponent(figuraInicial, javax.swing.GroupLayout.PREFERRED_SIZE, 426, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        PanelPrincipalLayout.setVerticalGroup(
            PanelPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(figuraInicial, javax.swing.GroupLayout.DEFAULT_SIZE, 455, Short.MAX_VALUE)
        );

        jToolBar1.setOrientation(1);
        jToolBar1.setRollover(true);

        Conc.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resource/Wireless-32.png"))); // NOI18N
        Conc.setText("Conceitos");
        Conc.setBorderPainted(false);
        Conc.setFocusable(false);
        Conc.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        Conc.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        Conc.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ConcActionPerformed(evt);
            }
        });
        jToolBar1.add(Conc);

        Tipos.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resource/Bluetooth-48.png"))); // NOI18N
        Tipos.setText("Tipos");
        Tipos.setBorderPainted(false);
        Tipos.setFocusable(false);
        Tipos.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        Tipos.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        Tipos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                TiposActionPerformed(evt);
            }
        });
        jToolBar1.add(Tipos);

        Montar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resource/Tools-48.png"))); // NOI18N
        Montar.setText("Montar");
        Montar.setBorderPainted(false);
        Montar.setFocusable(false);
        Montar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        Montar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        Montar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                MontarActionPerformed(evt);
            }
        });
        jToolBar1.add(Montar);

        Principal.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resource/Back-48.png"))); // NOI18N
        Principal.setText("Principal");
        Principal.setBorderPainted(false);
        Principal.setFocusable(false);
        Principal.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        Principal.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        Principal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                PrincipalActionPerformed(evt);
            }
        });
        jToolBar1.add(Principal);

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(PanelPrincipal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 569, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(229, 229, 229))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(PanelPrincipal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 455, Short.MAX_VALUE)))
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 800, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(870, 870, 870)
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(11, 11, 11)
                .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 573, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void ConcActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ConcActionPerformed
        offVisible();
        figuraInicial.setIcon(null);
        panelConceito.setSize(PanelPrincipal.getSize());
        panelConceito.setTipo(tipoDeRede);
        PanelPrincipal.add(panelConceito, new BorderLayout());
        panelConceito.setVisible(true);
        panelConceito.insereConceito();
        PanelPrincipal.repaint();
        repaint();
    }//GEN-LAST:event_ConcActionPerformed

    private void TiposActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TiposActionPerformed
        offVisible();
        figuraInicial.setIcon(null);
        panelTipo.setSize(PanelPrincipal.getSize());
        panelTipo.setSubtipos(tipoDeRede.getSubtipos());
        panelTipo.ajustar();
        PanelPrincipal.add(panelTipo, new BorderLayout());
        panelTipo.setVisible(true);
        
        PanelPrincipal.repaint();
        repaint();
    }//GEN-LAST:event_TiposActionPerformed


    private void MontarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MontarActionPerformed
        PainelMontagemWPan painel = new PainelMontagemWPan();
        painel.setVisible(true);
        painel.setFrameGuia(this);
        dispose();
    }//GEN-LAST:event_MontarActionPerformed

    private void PrincipalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PrincipalActionPerformed
        new FramePrincipal().setVisible(true);
        dispose();
    }//GEN-LAST:event_PrincipalActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new FrameGuia().setVisible(true);
            }
        });
    }

    public void ajustaAmbiente() {
        
    }


    public PanelConceito getPanelConceito() {
        return panelConceito;
    }

    public PanelTipo getPanelTipo() {
        return panelTipo;
    }
    

    

    public void setarFullScreen() {
        Insets in = Toolkit.getDefaultToolkit().getScreenInsets(this.getGraphicsConfiguration()); //recupera aspectos gráficos do ambiente

        Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); //recupera dimensão do ambiente

        int width = d.width - (in.left + in.top);
        int height = d.height - (in.top + in.bottom);
        setSize(width, height); //calcula dimensões de tela cheia e atribui ao programa
        setLocation(in.left, in.top); //posiciona frame em tela cheia para evitar que haja perda das laterais
    }
      public void offVisible(){
        if(panelTipo.isVisible()){
            panelTipo.setVisible(false);
        }
         if(panelConceito.isVisible()){
            panelConceito.setVisible(false);
        }
         if(panelBotoes.isVisible()){
            panelBotoes.setVisible(false);
        }
      }



    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Conc;
    private javax.swing.JButton Montar;
    private javax.swing.JPanel PanelPrincipal;
    private javax.swing.JButton Principal;
    private javax.swing.JButton Tipos;
    private javax.swing.JLabel figuraInicial;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JToolBar jToolBar1;
    // End of variables declaration//GEN-END:variables
}
